package com.rkc.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;

/**
 * @author `RKC`
 * @date 2022/3/5 14:23
 */
public class AlipayConfiguration {

    /**
     * 支付宝APPID
     */
    public static final String APPID = "2021000119629706";

    /**
     * 支付宝网关地址
     */
    public static final String PAY_GATEWAY = "https://openapi.alipaydev.com/gateway.do";

    /**
     * 签名类型
     */
    public static final String SIGN_TYPE = "RSA2";

    /**
     * 字符编码
     */
    public static final String CHARSET = "UTF-8";

    /**
     * 返回参数格式
     */
    public static final String FORMAT = "json";

    /**
     * 应用私钥
     */
    public static final String APP_PRI_KEY = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCl0OmMpKB5VZ70We7mb0oCSESXn2YEJlWaqheChOdvliCPuJHfYmlDkvu6zbwrE4jnEmulNlTUEIObknHXxT+tcRQuqnW4AB2QwIsAzF7OUZ0xCxo6JC1uO9ATDnw/VyBxAouOGhIk0V/Wd5U5rTdskOqvxSfpKrqgNfnyHDG/o/mxQObzVBi0FY+l4uk+837rQ3v8Nmg3dQSfFc4rkyPbuCqk3zGj7ul0LFIAtH1d/VhEHJUUNDWMXk/I2SaXwGhssReXcBGzySDf/oA1yWnPPHvjr+C9Ng0L/hTSzgzAWAEtfXjxEFj8+vgeW5/GlJRQ+bKysIZswxqcPkjfeftVAgMBAAECggEAJ7FCtvARmfns+wEsNu0dAj7abJEzknq6szNUPWIjJIsDcGP2R0r/d7WPnL/y8zzR4L6AFiRTWhA58Nu1dLk67QHMmv8i/tDIQwZUP/SsHSdcQYku1gwi8+hNfsJQ67ing2XgkjubbETSdDxb9FqKkep+w2SmkSIxWniRRGuLXRw32G3/xGTgBaJgYYxjxIoBqOiaWIKzeIjwk+pt38TG9Eb19QTzpB2VVAguCEu+71ZDYDm32Q2rOtLHXBnz03r4LDBSoVJYR1qMgE9hCXGpXtWLEL81Fh95wVjhgXxDJRQwSig+SbtyqTSabMk4ss/xsA/dGDHsiVmdHpTP/WuJYQKBgQDt3chKPs26tOgZsRqDx5WXFLQGlHf6vTa2Z9ReATX1BNRCJbDGg6/g8vsvOejUz7s2YUPFsj4VpWHxv7nhmO6YDVJjF6tmrd5x2e4h53lxJZ+ez91luryYb4HDY7y63mC5OGsUvbFud0aPJT+JRJrfJJxudsOkC1kCtIgpVa7JEwKBgQCydP3D9do8Z9YHDxM+KCl0pji5I+iHZz4Gumeop+fX4PnvFvVb9xq3zRRh0oQAXNPG66QRhinANE0jszOixOCBiWXGGI5Vv8SAX0s49Ng3DiaO6JMSGDN8K2PcCOMH+NKCmWuL/B8jXT9hxTk9mweaR+JWxUZ98AAdg/FqCxte9wKBgGv99wMORGTx4TZY28rcgCPZeGpMWbRy1zY1KYuMTSzyhlOJvRpDi0Q7zKKCThzgOwTTX+uPovQ845zYCNJNlnVeBvuKMX0qjwVthdnKt64RAMkfYkrfXuRuK6HD1FmawJsW7Da8cKPQby5qINB3X0DT5FmaffQqWr0JrY/moLYVAoGAI+ObVVmQNi27wVeqywlQrQDwz2sFTJXax4edaTG7UpMQMKExXvlnCifYPYQUv+3rOUoSiOOuadUa3l8ft1BYxjRXn2s41M3oOtjvS9kR0qCp6HuleDIdyI8BWjL/VY8Y5uLr2g8uQ/Jw2LzNMjKHaOOkBUdPUex+WXE7j9QEASkCgYA46clVWdv1fLdu5mfKlWYy/hQEWI7KAaOn45SFBs2GdnrWXB6TlH7XN8kOmTdOL0MoxQJxwJIboSJwgm1MxWikPSxhFgcyvsgVHBJEbYRHTANqkc42VnC+r3wj8gSQHE09ENfbLWplrKOrC4lt+LBEdCMTt/+NRoByQY6MHiAjnQ==";

    /**
     * 支付宝公钥
     */
    public static final String ALIPAY_PUB_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgRoY+dajIPm7iQtJlsK5i8IAlmbYAqOSNzle2u7XGrwvoQcDZ0zUXCJozUnTt92vnGNqu8TLyAd0KM0yTsgFM47pbtJJv7G1saia94AtDsKayNZLHtK6yyXccZ1KfzhT5SXpubA6QeJVERvS0G2kdQmhNZrBHhcy4LMB6DFiBgV3qJADxT3f3n98X+cpCQXia5fvIaE2OPrcaeD/aWNUQN/lRseEe/rvG+wC2fzm2w6bCu+gegR+h4DJTwq7zNuc78f89w46psYKkdCsRxKGnyAhraesLZPVbM5NbMMX+A+7K7LuXFom9vHkQZ5XpdH/3vqdy7QrAZHYdQNLyBIgPQIDAQAB";

    private static volatile AlipayClient instance = null;

    private AlipayConfiguration() {}

    /**
     * 双重锁校验单例
     * @return
     */
    public static AlipayClient getInstance() {
        if (instance == null) {
            synchronized (AlipayConfiguration.class) {
                if (instance == null) {
                    instance = new DefaultAlipayClient(PAY_GATEWAY, APPID, APP_PRI_KEY, FORMAT, CHARSET, ALIPAY_PUB_KEY, SIGN_TYPE);
                }
            }
        }
        return instance;
    }
}
